package org.ListBeastEngine.tools;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class AppendTestCases {

	public static void main(String args[]) {

		int i = 119; //starting test case number
		
		try {
			FileReader in = new FileReader("testInputData.txt");
			BufferedReader reader = new BufferedReader(in);

			FileWriter out = new FileWriter("src/test/com/listbeaster/filters/SongFilterTest.java", true);
			BufferedWriter writer = new BufferedWriter(out);
			
			do {
				String line = reader.readLine();
				if (line != null) {

					String[] words = line.split("::::");
					System.out.println(words[0] + "|" + words[1] + "|" + words[2] + "|" + words[3]);

					writer.write("	@Test");
					writer.newLine();
					writer.write("	public void testSongPair" + i + "() {");
					writer.newLine();
					writer.newLine();
					writer.write("		String youtubeSong = \"" + words[2] + "\";");
					writer.newLine();
					writer.write("		String librarySong = \"" + words[1] + "\";");
					writer.newLine();
					writer.write("		String artistName = \"" + words[0] + "\";");
					writer.newLine();
					writer.newLine();

					if (words[3].equalsIgnoreCase("ok")) {
						writer.write("		testMatch(artistName, youtubeSong, librarySong);");
					} else if (words[3].equalsIgnoreCase("nok")) {
						writer.write("		testNOMatch(artistName, youtubeSong, librarySong);");
					} else {
						throw new OKException("'ok' or 'nok' are only allowed!");
					}
					writer.newLine();
					writer.newLine();
					writer.write("	}");
					writer.newLine();
					writer.newLine();
				} else {
					break;
				}
				
				i++;
			} while (true);

			writer.close();

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (OKException e) {
			e.printStackTrace();
		}

	}
}
